package com.leetcode.LC;

public class LC693 {
    public boolean hasAlternatingBits(int n) {

        String s = Integer.toBinaryString(n);
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == s.charAt(i + 1)) {
                return false;
            }
        }
        return true;
    }

    public boolean hasAlternatingBits2(int n) {

        String s = Integer.toBinaryString(n);
        if (s.contains("00") || s.contains("11")) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new LC693().hasAlternatingBits(5));
    }
}
